<?php defined('BASEPATH') OR exit('No direct script access allowed');

if ( ! function_exists('upload_image') ) {
	function upload_image($name = 'upload',$folder,$max_width = 2000, $max_height = 2000){
		$image = NULL;
		$config['upload_path'] = './uploads/'.$folder.'/';
		$config['allowed_types'] = 'gif|jpg|jpeg|png';
		$config['file_name'] = time();
		$config['max_width']  = $max_width;
		$config['max_height']  = $max_height;
		
		$ci = & get_instance();
		$ci->load->library('upload',$config);
		if($ci->upload->do_upload($name)){
			$image = $ci->upload->data();
		}
		
		return $image;
		
		
	}
}